package loadsave.loadsaveobject;

import loadsave.Saver;

public class LoadSavePrimitive extends LoadSaveObject {

	private String value;
	
	public LoadSavePrimitive(String name, String type, String newVal) {
		super(name, type);
		this.value = newVal;
	}
	
	@Override
	public Iterator<LoadSaveObject> getIterator() {
		return new Iterator<LoadSaveObject>() {

			@Override
			public void init() { }

			@Override
			public boolean hasNext() {
				return false;
			}

			@Override
			public void next() { }

			@Override
			public LoadSaveObject getCurrKey() {
				throw new RuntimeException("This operation is not supported for this Iterator");
			}

			@Override
			public LoadSaveObject getCurrVal() {
				throw new RuntimeException("This operation is not supported for this Iterator");
			}
			
		};
	}
	
	@Override
	public String getValue() {
		return value;
	}
	
	@Override
	public void save(Saver s) {
		s.saveLoadSavePrimitive(this);
	}

	@Override
	public String toString() {
		return "LoadSavePrimitive: " + getName() + ":" + getType() + " = " + getValue() + "\n";
	}

}
